package com.lizk.study.netty.day005;

import java.io.*;

/**
 * @author lizhikui
 * @date 2019/6/22 8:36
 */
public class Client {

    public static void main(String[] args) throws IOException {

        //写对象到文件中

       /* User.Person user = User.Person.newBuilder()
                .setAge(16)
                .setSex(true)
                .setEmail("lzkmm@sina.com")
                .setName("lizhikui")
                .build();
        byte[] bytes = user.toByteArray();
        OutputStream os = new FileOutputStream(Client.class.getResource("").getPath()+"/user.bin");
        os.write(bytes);
        os.flush();
        os.close();
*/
        //读取序列化文件到系统中
        InputStream is = new FileInputStream(Client.class.getResource("").getPath()+"/user.bin");
        User.Person person = User.Person.parseFrom(is);
        System.out.println(person.getEmail());
        System.out.println(person.getName());
        System.out.println(person.getAge());
        System.out.println(person.getSex());


    }
}
